//当前这个模块:API进行统一管理
import request from '@/api/request'
import mockRequest from '@/api/mockAjax'

//三级联动接口
///api/product/getBaseCategoryList get 无参数

export const reqCategoryList = () => {
    //发请求:axios发请求返回Promise对象
    return request({ url: '/product/getBaseCategoryList', method: 'GET' })
}

//获取banner
export const reqGetBannerList = () => {
    return mockRequest({ url: '/banner', method: 'GET' })
}

//获取floor数据
export const reqFloorList = () => {
    return mockRequest({ url: '/floor', method: "GET" })
}

//获取搜索模块数据 /api/list post
//参数  
// {
//   "category3Id": "61",
//   "categoryName": "手机",
//   "keyword": "小米",
//   "order": "1:desc",
//   "pageNo": 1,
//   "pageSize": 10,
//   "props": ["1:1700-2799:价格", "2:6.65-6.74英寸:屏幕尺寸"],
//   "trademark": "4:小米"
// }
export const reqGetSearchInfo = (params) => {
    return request({ url: "/list", method: "POST", data: params })
}


//获取产品详情信息的接口 url:/api/item/{ skuId } get
export const reqGoodsInfo = (skuId) => {
    return request({ url: `/item/${skuId}`, method: "get" })
}


//将产品添加到购物车中 url:/api/cart/addToCart/{ skuId }/{ skuNum } post
export const reqAddOrUpdateShopCar = (skuId, skuNum) => {
    return request({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: "POST" })
}

//获取购物车列表数据接口
//url: /api/cart/cartList get
export const reqCartList = () => {
    return request({ url: '/cart/cartList', method: 'get' })
}

//删除购物产品信息
//url:/api/cart/deleteCart/{skuId} delete
export const reqDeleteById = (skuId) => {
    return request({ url: `/cart/deleteCart/${skuId}`, method: "delete" })
}

//修改商品选中状态
//url: /api/cart/checkCart/{skuID}/{isChecked} get
export const reqUpdateCheckedByid = (skuId, isChecked) => {
    return request({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: "get" })

}

//获取验证码
//url: /user/passport/sendCode/{phone} get
export const reqGetCode = (phone) => {
    return request({ url: `/user/passport/sendCode/${phone}`, method: "get" })
}


//用户注册
//url: /api/user/passport/register post
export const reqUserRegister = (data) => {
    return request({ url: "/user/passport/register", data, method: "post" })
}

//用户登录 url:/api/user/passport/login post
export const reqUserLogin = (data) => {
    return request({ url: "/user/passport/login", data, method: "post" })
}

//获取用户信息[需要带着token向服务器要登录信息]
//url:/user/passport/auth/getUserInfo get
export const reqUserInfo = () => {
    return request({ url: "/user/passport/auth/getUserInfo", method: "get" })
}

//退出登录
export const reqLogout = () => {
    return request({ url: "/user/passport/logout", method: "get" })
}

//获取用户地址信息
export const reqAddressInfo = () => {
    return request({ url: "/user/userAddress/auth/findUserAddressList", method: 'get' })
}

//获取商品清单
export const reqOrderInfo = () => {
    return request({ url: "/order/auth/trade", method: 'get' })
}

//提交订单
// /api/order/auth/submitOrder?tradeNo={tradeNo} post
export const reqSubmitOrder = (tradeNo, data) => {
    return request({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, data, method: "post" })
}

//获取支付信息
///api/payment/weixin/createNative/{orderId} get
export const reqPayInfo = (orderId) => {
    return request({ url: `/payment/weixin/createNative/${orderId}`, method: "get" })
}

// 获取支付订单状态
// /api/payment/weixin/queryPayStatus/{orderId} get
export const reqPayStatus = (orderId) => {
    return request({ url: `/payment/weixin/queryPayStatus/${orderId}`, method: "get" })
}

//获取个人中心数据
///api/order/auth/{page}/{limit} get
export const reqMyOrderList = (page, limit) => {
    return request({ url: `/order/auth/${page}/${limit}`, method: "get" })
}


